home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / Resources / CutePDF 2.3 / converter.exe / GNUGS / GS_STATD.PS < prev    next >
Text File  |  2002-07-19  |  13KB  |  366 lines

  1. %    Copyright (C) 1989, 2000 Aladdin Enterprises.  All rights reserved.
  2. % This software is provided AS-IS with no warranty, either express or
  3. % implied.
  4. % This software is distributed under license and may not be copied,
  5. % modified or distributed except as expressly authorized under the terms
  6. % of the license contained in the file LICENSE in this distribution.
  7. % For more information about licensing, please refer to
  8. % http://www.ghostscript.com/licensing/. For information on
  9. % commercial licensing, go to http://www.artifex.com/licensing/ or
  10. % contact Artifex Software, Inc., 101 Lucas Valley Road #110,
  11. % San Rafael, CA  94903, U.S.A., +1(415)492-9861.
  12.  
  13. % $Id: gs_statd.ps,v 1.5.2.2 2002/07/18 10:43:42 ghostgum Exp $
  14. % This file provides statusdict, serverdict, and assorted LaserWriter
  15. % operators, mostly for the benefit of poorly designed PostScript programs
  16. % that 'know' they are running on a LaserWriter.
  17.  
  18. systemdict begin
  19.     % We make statusdict a little larger for Level 2 stuff.
  20.     % Note that it must be allocated in local VM.
  21.  .currentglobal false .setglobal
  22.  /statusdict 89 dict .forcedef        % statusdict is local, sys'dict global
  23.     % To support the Level 2 job control features,
  24.     % serverdict must also be in local VM.
  25.  /serverdict 10 dict .forcedef        % serverdict is local, sys'dict global
  26.  .setglobal
  27. end
  28.  
  29. % Define various paper formats.  The Adobe documentation defines only these:
  30. % 11x17, a3, a4, a4small, b5, ledger, legal, letter, lettersmall, note.
  31. % These procedures are also accessed as data structures during initialization,
  32. % so the page dimensions must be the first two elements of the procedure.
  33.  
  34. /.setpagesize { /statusdict .systemvar begin .setpagesize end } bind def
  35. userdict begin
  36.         % Page sizes defined by Adobe documentation
  37.  /11x17 {792 1224 //.setpagesize exec} bind def  % 11x17 portrait
  38.  /a3 {842 1191 //.setpagesize exec} bind def
  39.  /a4 {595 842 //.setpagesize exec} bind def
  40. % a4small should be a4 with an ImagingBBox of [25 25 570 817].
  41.  /a4small /a4 load def
  42. % b5 see below.
  43.  /ledger {1224 792 //.setpagesize exec} bind def  % 11x17 landscape
  44.  /legal {612 1008 //.setpagesize exec} bind def
  45.  /letter {612 792 //.setpagesize exec} bind def
  46. % lettersmall should be letter with an ImagingBBox of [25 25 587 767].
  47.  /lettersmall /letter load def
  48. % note should be letter (or some other size) with the ImagingBBox
  49. % shrunk by 25 units on all 4 sides.
  50.  /note /letter load def
  51.         % End of Adobe-defined page sizes
  52. STRICT { (%END SIZES) .skipeof } if
  53.         % Other page sizes
  54.     % ISO standard paper sizes
  55.  /a0 {2384 3370 //.setpagesize exec} bind def
  56.  /a1 {1684 2384 //.setpagesize exec} bind def
  57.  /a2 {1191 1684 //.setpagesize exec} bind def
  58. % /a3 {842 1191 //.setpagesize exec} bind def    % defined by Adobe
  59. % /a4 {595 842 //.setpagesize exec} bind def    % defined by Adobe
  60.  /a5 {420 595 //.setpagesize exec} bind def
  61.  /a6 {297 420 //.setpagesize exec} bind def
  62.  /a7 {210 297 //.setpagesize exec} bind def
  63.  /a8 {148 210 //.setpagesize exec} bind def
  64.  /a9 {105 148 //.setpagesize exec} bind def
  65.  /a10 {73 105 //.setpagesize exec} bind def
  66. % ISO and JIS B sizes are different....
  67.  /isob0 {2835 4008 //.setpagesize exec} bind def
  68.  /b0 /isob0 load def
  69.  /isob1 {2004 2835 //.setpagesize exec} bind def
  70.  /b1 /isob1 load def
  71.  /isob2 {1417 2004 //.setpagesize exec} bind def
  72.  /b2 /isob2 load def
  73.  /isob3 {1001 1417 //.setpagesize exec} bind def
  74.  /b3 /isob3 load def
  75.  /isob4 {709 1001 //.setpagesize exec} bind def
  76.  /b4 /isob4 load def
  77.  /isob5 {499 709 //.setpagesize exec} bind def
  78.  /b5 /isob5 load def
  79.  /isob6 {354 499 //.setpagesize exec} bind def
  80.  /b6 /isob6 load def
  81.  /jisb0 {2920 4127 //.setpagesize exec} bind def
  82.  /jisb1 {2064 2920 //.setpagesize exec} bind def
  83.  /jisb2 {1460 2064 //.setpagesize exec} bind def
  84.  /jisb3 {1032 1460 //.setpagesize exec} bind def
  85.  /jisb4 {729 1032 //.setpagesize exec} bind def
  86.  /jisb5 {516 729 //.setpagesize exec} bind def
  87.  /jisb6 {363 516 //.setpagesize exec} bind def
  88.  /c0 {2599 3677 //.setpagesize exec} bind def
  89.  /c1 {1837 2599 //.setpagesize exec} bind def
  90.  /c2 {1298 1837 //.setpagesize exec} bind def
  91.  /c3 {918 1298 //.setpagesize exec} bind def
  92.  /c4 {649 918 //.setpagesize exec} bind def
  93.  /c5 {459 649 //.setpagesize exec} bind def
  94.  /c6 {323 459 //.setpagesize exec} bind def
  95.     % U.S. CAD standard paper sizes
  96.  /archE {2592 3456 //.setpagesize exec} bind def
  97.  /archD {1728 2592 //.setpagesize exec} bind def
  98.  /archC {1296 1728 //.setpagesize exec} bind def
  99.  /archB {864 1296 //.setpagesize exec} bind def
  100.  /archA {648 864 //.setpagesize exec} bind def
  101.     % Other paper sizes
  102.  /flsa {612 936 //.setpagesize exec} bind def  % U.S. foolscap
  103.  /flse {612 936 //.setpagesize exec} bind def  % European foolscap
  104.  /halfletter {396 612 //.setpagesize exec} bind def
  105. % /tabloid {792 1224 //.setpagesize exec} bind def  % 11x17 portrait
  106. % /csheet {1224 1584 //.setpagesize exec} bind def % ANSI C 17x22
  107. % /dsheet {1584 2448 //.setpagesize exec} bind def % ANSI D 22x34
  108. % /esheet {2448 3168 //.setpagesize exec} bind def % ANSI E 34x44
  109. %END SIZES
  110. end
  111. currentdict /.setpagesize .undef
  112.  
  113. statusdict begin
  114.  
  115. % Define the pagetype values for the known page formats.
  116. % The values for all but letter and note are arbitrary.
  117. /.pagetypenames
  118.  { /letter /note    %do not change this line, needed by 'setpagetype'
  119.    /legal /lettersmall
  120.    /11x17 /ledger
  121.    /a4small /a3 /a4
  122. STRICT { (%END SIZES) .skipeof } if
  123.    /a0 /a1 /a2 /a5 /a6 /a7 /a8 /a9 /a10
  124.    /archA /archB /archC /archD /archE
  125.    /b0 /b1 /b2 /b3 /b4 /b5 /b6
  126.    /c0 /c1 /c2 /c3 /c4 /c5 /c6
  127.    /flsa /flse /halfletter
  128.    /isob0 /isob1 /isob2 /isob3 /isob4 /isob5 /isob6
  129.    /jisb0 /jisb1 /jisb2 /jisb3 /jisb4 /jisb5 /jisb6
  130. %END SIZES
  131.  } cvlit readonly def
  132.  
  133. %%%%%% The following items were suggested by a user as useful.
  134.  
  135. % Permanent definitions
  136.  
  137. /ramsize         4194304 def
  138. /hardwareiomode        0 def
  139.     /sethardwareiomode     {pop} bind def
  140. /softwareiomode        0 def
  141.     /setsoftwareiomode     {pop} bind def
  142. /dosysstart        false def
  143.     /setdosysstart         {pop} bind def
  144. /allowjobreset      true def
  145.     /setallowjobreset      {pop} bind def
  146. /defaultpaperfamily    0 def
  147.     /setdefaultpaperfamily {pop} bind def
  148. /defaultpapertray      0 def
  149.     /setdefaultpapertray   {pop} bind def
  150. /defaulttrayswitch false def
  151.     /setdefaulttrayswitch  {pop} bind def
  152.  
  153. % Tray and format selection
  154.  
  155.  /11x17tray {/11x17 .uservar exec} bind def
  156.  /a3tray {/a3 .uservar exec} bind def
  157.  /a4tray {/a4 .uservar exec} bind def
  158.  /a5tray {/a5 .uservar exec} bind def
  159.  /a6tray {/a6 .uservar exec} bind def
  160.  /b4tray {/b4 .uservar exec} bind def
  161.  /b5tray {/b5 .uservar exec} bind def
  162.  /flsatray {/flsa .uservar exec} bind def
  163.  /flsetray {/flse .uservar exec} bind def
  164.  /halflettertray {/halfletter .uservar exec} bind def
  165.  /ledgertray {/ledger .uservar exec} bind def
  166.  /legaltray {/legal .uservar exec} bind def
  167.  /lettertray {/letter .uservar exec} bind def
  168.  
  169. % Per-job parameters
  170.  
  171. /paperfamily 0 def    % 0 is US, 1 is European
  172. /papertray 1 def
  173.     /setpapertray {statusdict exch /papertray exch put} bind def 
  174. /trayswitch false def    % paperout feeds from another tray
  175. % We don't implement the (undocumented by Adobe) papersize 'operator',
  176. % because it's very awkward to make it interact properly with all the
  177. % different ways of setting the paper size.
  178. %/papersize {/letter true} bind def    % <name of paper size>, <short-edge-first-p>
  179. /appletalktype (LaserWriter) def
  180.  
  181. %%%%%% The following items are defined in the PostScript Language
  182. %%%%%% Reference Manual, First Edition, and subsequent 'compatibility'
  183. %%%%%% documentation from Adobe.
  184.  
  185.  /checkpassword {statusdict begin .password eq end} bind def
  186.  /defaulttimeouts {statusdict begin .timeouts aload pop end} bind def
  187.  /diskonline {
  188.     false (%disk*%) { pop not exit } 100 string /IODevice resourceforall
  189.  } bind def
  190. %/dostartpage
  191.  /eescratch {pop 0} bind def
  192.  /idlefonts {statusdict begin mark .idlefonts aload pop end} bind def
  193.  /jobname () def
  194. %/jobtimeout
  195.  /manualfeed false def
  196.  /manualfeedtimeout 60 def
  197.  /margins {statusdict begin .topmargin .leftmargin end} bind def
  198.  /pagecount {4711} bind def
  199.  /pagestackorder {false} bind def
  200.  /pagetype 0 def
  201.  /prefeed false def
  202.  /printererror {pop pop} bind def
  203.  /printername {statusdict /.printername get exch copy} bind def
  204.  /processcolors /processcolors load def        % defined in systemdict
  205.  /product product def        % product is defined in systemdict
  206.  /revision revision def        % revision is defined in systemdict
  207.  /sccbatch {pop 9600 0} bind def
  208.  /sccinteractive {pop 9600 0} bind def
  209.  /setdefaulttimeouts {statusdict begin .timeouts astore pop end} bind def
  210.  /setdostartpage {statusdict exch /dostartpage exch put} bind def
  211.  /setduplexmode {mark /Duplex 3 -1 roll currentdevice putdeviceprops} bind def
  212.  /seteescratch {pop pop} bind def
  213.  /setidlefonts {] statusdict exch /.idlefonts exch put} bind def
  214.  /setjobtimeout {statusdict exch /jobtimeout exch put} bind def
  215.  /setmargins
  216.   { statusdict begin
  217.     /.leftmargin exch def /.topmargin exch def
  218.     end
  219.   } bind def
  220.  
  221. % The following compatibility operators are only documented by Adobe in a
  222. % supplement to the Red Book.
  223. %
  224. %    - pagemargin <offset>
  225. %    - pageparams <width> <height> <offset> <orientation>
  226. %    <width> <height> <orientation> setpage -
  227. %    <offset> setpagemargin -
  228. %    <width> <height> <offset> <orientation> setpageparams -
  229. %
  230. % width and height are in default units (and if orientation is odd, are
  231. % exchanged!).  offset is the x margin, also in default units.
  232. % Unfortunately, because orientation is relative to the device paper feed,
  233. % it does not have a consistent meaning in terms of image orientation.
  234. % We follow the convention that ORIENT1 determines the orientation value
  235. % that means portait: false means 0, true means 1.
  236.  
  237.  /pagemargin { 0 } bind def
  238.  /pageparams
  239.   { currentdevice 1 dict dup /.MediaSize dup put .getdeviceparams
  240.     exch pop exch pop aload pop 0 ORIENT1 { 1 } { 0 } ifelse
  241.   } bind def
  242.  /setpage
  243.   { ORIENT1 { 1 } { 0 } ifelse ne {exch} if
  244.     statusdict /.setpagesize get exec
  245.   } bind def
  246.  /setpagemargin {pop} bind def    % can't do better without setpagedevice
  247.  /setpageparams
  248.   { exch pop ORIENT1 { 1 } { 0 } ifelse ne {exch} if
  249.     statusdict /.setpagesize get exec
  250.   } bind def
  251.  /setpagetype
  252.   { statusdict begin
  253.         % The Adobe documentation only defines setpagetype
  254.         % (a Level 1 operator) as accepting the values 0 and 1,
  255.         % so we do too.
  256.       dup .pagetypenames 0 2 getinterval exch get //systemdict exch get exec
  257.       /pagetype exch def
  258.     end
  259.   } bind def
  260.  /setpassword
  261.   {exch checkpassword
  262.     {statusdict exch /.password exch put true}
  263.     {pop false}
  264.    ifelse} bind def
  265.  /setprintername
  266.   {dup length string copy statusdict exch /.printername exch put} bind def
  267.  
  268. % setresolution is not documented by Adobe, but some applications
  269. % use it anyway, without testing whether or not it is present.
  270. %
  271. %    <pixels_per_inch> setresolution -
  272. %
  273. % sets the resolution of the device.
  274.  
  275.  /setresolution
  276.   { mark /HWResolution [ 4 -1 roll dup ] currentdevice putdeviceprops pop
  277.     initmatrix erasepage
  278.   } bind def
  279.  /setsccbatch {pop pop pop} bind def
  280.  /setsccinteractive {pop pop pop} bind def
  281.  /settumble {pop} bind def
  282.  /waittimeout 300 def
  283.  
  284. %%%%%% End of documented items.
  285.  
  286. /.setpagesize
  287.  { mark /HWSize [
  288.      4 index 4 index matrix defaultmatrix dtransform
  289.      abs ceiling cvi exch abs ceiling cvi exch
  290.    ] currentdevice putdeviceprops pop pop pop
  291.    initmatrix initclip erasepage
  292.  } bind def
  293. /.password 0 def
  294. /.timeouts [0 60 30] def
  295. true setdostartpage
  296. mark setidlefonts
  297. 0 setjobtimeout
  298. 0 0 setmargins
  299. product setprintername
  300.  
  301. end    % statusdict
  302.  
  303. %%%%%% The following documented compatibility "operators" are in systemdict,
  304. %%%%%% not in statusdict.
  305.  
  306. systemdict begin
  307. .currentglobal true .setglobal
  308.  
  309. /devforall {        % <pattern> <proc> <scratch> devforall -
  310.   exch {
  311.     1 index currentdevparams
  312.     /Type .knownget { /FileSystem eq } { false } ifelse
  313.     { exec } { pop pop } ifelse
  314.   } /exec load 3 packedarray cvx exch
  315.   (*) 3 1 roll /IODevice resourceforall
  316. } odef
  317.  
  318. /devstatus {        % <(%disk*%)> devstatus <searchable> <writable>
  319.             %   <hasNames> <mounted> <removable> <searchOrder>
  320.             %   <freePages> <size> true
  321.             % <string> devstatus false
  322.   dup length 5 ge {
  323.     dup 0 5 getinterval (%disk) eq {
  324.       dup /IODevice resourcestatus {
  325.     pop pop dup currentdevparams
  326.     dup /Searchable get
  327.     exch dup /Writeable get
  328.     exch dup /HasNames get
  329.     exch dup /Mounted get
  330.     exch dup /Removable get
  331.     exch dup /SearchOrder get
  332.     exch dup /Free get
  333.     exch /LogicalSize get
  334.     9 -1 roll pop true
  335.       } {
  336.     pop false
  337.       } ifelse
  338.     } {
  339.       pop false
  340.     } ifelse
  341.   } {
  342.     pop false
  343.   } ifelse
  344. } odef
  345.  
  346. .setglobal end    % systemdict
  347.  
  348. % The following contents of serverdict are a complete guess,
  349. % based on some observed LaserWriter boilerplate.
  350.  
  351. serverdict begin
  352.  
  353.  /execjob { } bind def
  354. % The Red Book implies that something like the following is
  355. % an appropriate definition of exitserver.
  356.  /exitserver { clear stop } bind def
  357. % However, this interacts badly with our standard error handler,
  358. % so we override it with the following less appropriate definition.
  359.  /exitserver { 0 ne { clear cleardictstack } if } bind def
  360.  /setrealdevice { } bind def
  361.  
  362. end    % serverdict
  363.